<template>
	<div class="main">
		<van-field label="标题" v-model="data.Title" name="title" required>
		</van-field>

		<!-- 单选框 -->
		<van-field
			class="input_text"
			label='受理部门'
			required	
			:border="false"
		>
			<template #input>
				<van-radio-group v-model="data.CompanyPCode" direction="horizontal" >
					<van-radio
						v-for="(item, index1) in data.CompanyList"
						:key="index1"
						:name="item.ID"
						style="margin:10px 10px 0 0"
						>{{ item.Name }}</van-radio>
				</van-radio-group>
			</template>
		</van-field>
		
		<FileUpload
        @CallBack="_fileUploadCb"
        :attachs="data.Attachs"
        :labelName="'附件'"
        :mustInput="true"
      />

		
		<van-field
			label="反馈内容"
			rows="3"
			autosize
			type="textarea"
			v-model="data.Contents"
			required
		>
		</van-field>

		<div class="bottom_submit">
			<van-button type="primary" @click="_submit(10)" > 暂存 </van-button>
			<van-button type="info" @click="_submit(20)" style="margin-left: 10px;"> 保存并提交 </van-button>
		</div>

		
	</div>
</template>

<script>
import { formatDate, getDate } from '@/utils/getDate'
import store from '@/store/index'
export default {
	
	data() {
		return {
			id: this.$route.query.id,
			data: {
				
			},
			menuList: [],
			mobile: '',
			message: '',
			radio: '1',
			checkbox: false,
			checkboxGroup: [],
			value: '',
			showCalendar: false,
			activeNames: ['1'],
			ChemPropsList: [
				{ ID: '1', Name: '易制毒' },
				{ ID: '2', Name: '重大危险源' },
				{ ID: '3', Name: '剧毒' },
				{ ID: '4', Name: '易制爆' },
				{ ID: '5', Name: '其它伤害' },
			],
			showPopup: false,
			MannerItemPopup: false,
			userId: [],
			show: false,
			Component: '',
			CASNo: '',
		}
	},
	beforeMount () {
		this.data = []

		let title = '新增反馈'
		if (this.id != 0) {
			this.getDetail()
			title = '编辑反馈'
		} else {
			this.initNewEntity();
		}
		store.commit('updateTitle', title)
	},
	created() {
		

	},
	activated() {},
	methods: {
		getDetail() {
			let params = { id: this.id };
			this.$axios
				.get('/YatFeedback/GetDetail', { params: params })
				.then((res) => {
				this.data = res.data;
				});
		},
		_fileUploadCb(attachs) {
			this.data.Attachs = attachs;
		},
		initNewEntity() {
			this.$axios
				.get('/YatFeedback/InitNewEntity', {})
				.then((res) => {
				this.data = res.data;
				});
		},
		// 保存
		_submit(states) {
			if (!this.data.Title) {
				this.$toast('请输入标题')
				return
			}

			if (!this.data.Contents) {
				this.$toast('请输入反馈内容')
				return
			}

			if (!this.data.CompanyPCode) {
				this.$toast('请选择受理部门')
				return
			}
			
			this.data.Status = states;

		if (this.id != 0) {
			this.$axios
            .post('/YatFeedback/Update', this.data)
            .then((res) => {
              this.$toast.success("保存成功");
              this.$router.push("/YatFeedback");
            });
        } else {
			this.$axios
				.post('/YatFeedback/Add', this.data)
				.then((res) => {
				this.$toast.success("新增成功");
				this.$router.push("/YatFeedback");
				});
        }
		},
	},
}
</script>

<style lang="less" scoped>
.col-detail {
	color: #333;
	display: flex;
	align-items: center;
	justify-content: space-between;

	.col-del {
		display: flex;
		align-items: center;
		img {
			width: 15px;
			height: 15px;
			margin-right: 5px;
		}
	}
}
.valueclass {
	color: rgb(0, 195, 224);
}
.dialog-content-text {
	height: auto;
}
.bottom_submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 15px;
  box-sizing: border-box;
  .van-button {
    width: 100%;
    height: 35px;
	
  }
}

</style>
